package com.xigua.chapter_7_Builder;

import com.xigua.chapter_7_Builder.framework.Director;
import com.xigua.chapter_7_Builder.framework.HtmlBuilder;
import com.xigua.chapter_7_Builder.framework.TextBuilder;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2022/4/1415:49
 */
public class Main {

    public static void main(String[] args) {

        if (args.length != 1 || (!args[0].equals("plain") && !args[0].equals("html")) ){
            usage();
            System.exit(0);
        }
        Director director;
        if (args[0].equals("plain")){
            TextBuilder textBuilder = new TextBuilder();
            director = new Director(textBuilder);
            director.construct();
            System.out.println(textBuilder.getReult());
        } else if (args[0].equals("html")) {
            HtmlBuilder htmlBuilder = new HtmlBuilder();
            director = new Director(htmlBuilder);
            director.construct();
            String result = htmlBuilder.getResult();
            System.out.println(result+"文件编写完成");
        }

    }

    public static void  usage(){
        System.out.println("Usage:java Main plain");
        System.out.println("Usage:java Main html");
    }

}
